import { lazy } from 'react'
import { Navigate, useRoutes } from "react-router-dom";
//导入懒加载组件
import LazyLoad from '@/components/LazyLoad'

// //路由组件(函数组件)
// const Routes = () => {
//     return (
//         <Suspense fallback={<Loading />}>
//             <Switch>
//                 <Redirect from="/" to="/Home" exact></Redirect>
//                 <Route path="/Home" component={Home}></Route>
//                 <Route path="/NewTask" component={NewTask}></Route>
//                 <Route path="/TaskDetail" component={TaskDetail}></Route>
//                 <Route component={Error404}></Route>
//             </Switch>
//         </Suspense>
//     )
// }
// //路由规则,除了嵌套路由,一律在根组件里面写

// 首页模块
const homeRouter = [
    {
		path: "/",
		element: <Navigate to="/login" />
	},
    {
		path: "/login",
        element: LazyLoad(lazy(() => import('@/views/login/Login'))),
	},
    {
        path: '/taskList',
        element: LazyLoad(lazy(() => import('@/views/TaskList'))),
    },
    {
        path: "/evaluationTask",
        element: LazyLoad(lazy(() => import('@/views/EvaluationTask'))),
        meta: {
            requiresAuth: true,
            key: "evaluationTask"
        }
    },
    {
        path: "/taskDetail",
        element: LazyLoad(lazy(() => import('@/views/TaskDetail'))),
        meta: {
            requiresAuth: true,
            key: "taskDetail"
        }
    },
	{
		path: "*",
		element: LazyLoad(lazy(() => import('@/components/Error404.jsx'))),
		meta: {
			requiresAuth: false,
			key: "404"
		}
	},
];


const Routes = () => {
	const routes = useRoutes(homeRouter);
	return routes;

};


export default Routes;





